package com.gowants.pems.controller;

import java.util.List;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.gowants.pems.model.PemsCity;
import com.gowants.pems.model.PemsProvince;
import com.gowants.pems.service.PemsProvinceService;
import com.gowants.pems.util.JSONMap;

@RestController
@RequestMapping(value = "/pemsProvince/")
public class PemsProvinceController extends BaseController {

	@Autowired
	private PemsProvinceService pemsProvinceService;

	/**
	 * 省列表查询
	 * 
	 * @param     request={"provinceCode":"","provinceName":""}
	 * @param req
	 * @return
	 */
	@RequestMapping(value = "common/provinceList")
	public JSONMap provinceListForPhone(String request, HttpServletRequest req) {
		String code = "";
		try {
			PemsProvince record = new PemsProvince();
			if ("".equals(request) || null == request) {

			} else {
				record = getRequestBody(request, PemsProvince.class);
			}
			List<PemsProvince> list = pemsProvinceService.select(record);
			return doResponse(req, code, list);

		} catch (Exception e) {
			code = e.getMessage();
			return doResponse(req, code, null);
		}
	}

	/**
	 * 市列表查询
	 * 
	 * @param     request={"cityCode":"","cityName":"","provinceCode":""}
	 * @param req
	 * @return
	 */
	@RequestMapping(value = "common/cityList")
	public JSONMap cityListForPhone(String request, HttpServletRequest req) {
		String code = "";
		try {
			PemsCity record = new PemsCity();
			if ("".equals(request) || null == request) {

			} else {
				record = getRequestBody(request, PemsCity.class);
			}
			List<PemsCity> list = pemsProvinceService.selectCity(record);
			return doResponse(req, code, list);

		} catch (Exception e) {
			code = e.getMessage();
			return doResponse(req, code, null);
		}
	}
	/**
	 * 省列表查询
	 * 
	 * @param     request={"provinceCode":"","provinceName":""}
	 * @param req
	 * @return
	 */
	@RequestMapping(value = "provinceList")

	public JSONMap provinceList(String request, HttpServletRequest req) {
		String code = "";
		try {
			PemsProvince record = new PemsProvince();
			if ("".equals(request) || null == request) {

			} else {
				record = getRequestBody(request, PemsProvince.class);
			}
			List<PemsProvince> list = pemsProvinceService.select(record);
			return doResponse(req, code, list);

		} catch (Exception e) {
			code = e.getMessage();
			return doResponse(req, code, null);
		}
	}

	/**
	 * 市列表查询
	 * 
	 * @param     request={"cityCode":"","cityName":"","provinceCode":""}
	 * @param req
	 * @return
	 */
	@RequestMapping(value = "cityList")
	public JSONMap cityList(String request, HttpServletRequest req) {
		String code = "";
		try {
			PemsCity record = new PemsCity();
			if ("".equals(request) || null == request) {

			} else {
				record = getRequestBody(request, PemsCity.class);
			}
			List<PemsCity> list = pemsProvinceService.selectCity(record);
			return doResponse(req, code, list);

		} catch (Exception e) {
			code = e.getMessage();
			return doResponse(req, code, null);
		}
	}

	

}
